package com.example.servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;

//请求转发
public class Servlet1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取请求参数
        String username = request.getParameter("username");
        //使用域数据 并传递到servlet2
        request.setAttribute("key","servlet1的许可");
        //servlet2的问路
        RequestDispatcher requestDispatcher = request.getRequestDispatcher("/servlet2");
                                                   //      可转发至html文件      /WEB-INF/MuchServlet.html
                                                    //不可访问工程外资源
        //前往servlet2
        requestDispatcher.forward(request,response);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
